<template>
	<!-- 地址选择 -->
	<view class="myBody">
		<radio-group @change="radioChange">
			<label v-for="(item, index) in harvestData" :key="index" class="Harvest">
				<view>
					<radio :value="JSON.stringify(item)" :checked="item.id==nowAdress.id" />
				</view>
				<view>
					<view>
						<text>{{item.name}}</text>
						<text>{{item.phone}}</text>
						<text class="FreeOfMail" v-if="item.type==1">默认</text>
					</view>
					<view>
						<text class="iconfont .icon-weizhi" />
						<text>{{item.area}} {{item.place}}</text>
					</view>
				</view>
			</label>
		</radio-group>
	</view>
	<view class="Footer" @click="AdressOK">确认选择</view>
</template>

<script>
	import {
		reactive
	} from 'vue';
	import store from '../../store/index.js';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	export default {
		setup() {
			let data = reactive({
				harvestData: [],
				nowAdress: {},
				selectAdress: store.state.nowUserOrderHarvest,
				radioChange: function(evt) {
					data.selectAdress = JSON.parse(evt.detail.value);
				},
				AdressOK: function() {
					store.commit('editNowUserOrderHarvest', data.selectAdress);
					uni.navigateBack({
						delta: 1
					});
				}
			});
			onLoad(function() {
				data.harvestData = store.state.userOrderHarvest;
				data.nowAdress = store.state.nowUserOrderHarvest;
			})
			return data;
		}
	}
</script>

<style>
	@import url('~@/static/Mall/iconfont.css');

	.myBody {
		padding-bottom: 120rpx;
	}

	.Harvest {
		display: flex;
		align-items: center;
		height: 200rpx;
		font-size: 28rpx;
		color: #999999;
		border-bottom: 2rpx solid #E4E4E4;
	}

	.Harvest>view:first-child {
		padding: 0 20rpx;
	}

	.Harvest>view:last-child>view:first-child {
		margin-bottom: 10rpx;
	}

	.Harvest>view:last-child>view:first-child>text:not(:first-child) {
		margin-left: 20rpx;
	}

	.FreeOfMail {
		margin-right: 20rpx;
		padding: 3rpx 30rpx;
		font-size: 24rpx;
		color: #F19736;
		border: 1rpx solid #F19736;
		border-radius: 20rpx;
	}

	.Footer {
		position: fixed;
		bottom: 0;
		width: 750rpx;
		height: 120rpx;
		font-size: 36rpx;
		text-align: center;
		line-height: 120rpx;
		color: #FFFFFF;
		background-color: #3478F7;
	}
</style>
